// App可以认为是我们自己写的业务组件
import React, { Component } from "react";
import Modal from "./Modal";

class App extends Component {
  state = {
    show: false,
  };

  open = () => {
    this.setState({
      show: true,
    });
  };

  handleOk = () => {
    console.log("确定");
  };

  handleCancel = () => {
    console.log("取消");
    this.setState({
      show: false,
    });
  };

  render() {
    return (
      <div className="wrap">
        <h2>modal对话框</h2>
        <button onClick={this.open}>打开</button>
        {/* 不要这么写 */}
        {/* {this.state.show && <Modal />} */}

        <Modal
          open={this.state.show}
          title="Basic Modal"
          onOk={this.handleOk}
          onCancel={this.handleCancel}
          okText="通过"
          cancelText="不通过"
          // width={800}
        >
          <p>Some contents...</p>
          <p>Some contents...</p>
          <p>Some contents...</p>
        </Modal>
      </div>
    );
  }
}

export default App;
